/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.component.gateway.dianlan.protocol.active;

import info.peigen.hotpot.component.gateway.dianlan.annotations.DianlanProtocol;
import info.peigen.hotpot.component.gateway.dianlan.facade.enums.DianlanRemoteStartChargeFailReason;
import info.peigen.hotpot.component.gateway.dianlan.facade.enums.DianlanSuccessSign;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;
import lombok.experimental.SuperBuilder;

import static info.peigen.hotpot.component.gateway.dianlan.annotations.DianlanProtocol.DianlanProtocolDataType.BCD;
import static info.peigen.hotpot.component.gateway.dianlan.annotations.DianlanProtocol.DianlanProtocolDataType.ENUM;

/**
 * <b>(DianlanRemoteStartChargeResponse)</b>
 * <p>
 * 远程控制启机-应答
 * 远程启动充电命令回复
 * 帧类型码 0x33
 * 序列号域 0002
 * 数据长度 1E(30)
 * 帧校验域 0FE2
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2022/8/11
 */
@SuperBuilder
@Data
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
@Accessors(chain = true)
public class DianlanRemoteStartChargeResponse {
    /** 交易流水号 */
    @DianlanProtocol(length = 16, start = 0, end = 16, dataType = BCD)
    String                             transNo;
    /** 桩编码 */
    @DianlanProtocol(length = 7, start = 16, end = 23, dataType = BCD)
    String                             stubNo;
    /** 充电枪号 */
    @DianlanProtocol(length = 1, start = 23, end = 24, dataType = BCD)
    String                             chargingPortNo;
    /** 启动结果 */
    @DianlanProtocol(length = 1, start = 36, end = 37, dataType = ENUM)
    DianlanSuccessSign                 authSign;
    /**
     * 失败原因
     * <p>
     * 桩在收到启充命令后,检测到未插枪则发送 0x33 报文回复充电失败。
     * 若在 60 秒（以收到 0x34 时间开始计算）内检测到枪重新连接，则补送 0x33 成功报文;
     * 超时或者离线等其他异常，桩不启充、不补发 0x33 报文
     */
    @DianlanProtocol(length = 1, start = 37, end = 38, dataType = ENUM)
    DianlanRemoteStartChargeFailReason failReason;
}